<include file="Public:header" />
<div class="page-member subpage">
    <div class="form-header">
        <div>
            <div class="line1">
                <div class="fl"><h3>用户信息 / 修改密码</h3></div>
            </div>
            <div class="line2">
                <div class="fl form-btn-group">
                    <button onclick="submitForm();" class="btn-save btn-highlight">修 改</button>
                    <span>或</span>
                    <a onclick="window.history.back();" class="linkBtn btn-abort" href="javascript:void(0);">放弃</a>
                </div>
            </div>
        </div>
    </div>
    <div class="form-box2">
        <div>
            <form id="passwdForm" method="post" action="">
                <table class="form">
                    <tr>
                        <th>用户名<span class="hint">*</span></th>
                        <td>{$username}</td>
                        <th></th>
                        <td></td>
                    </tr>
                    <tr>
                        <th>新密码<span class="hint">*</span></th>
                        <td><input name="newpwd" type="password" value="" /></td>
                        <th></th>
                        <td></td>
                    </tr>
                    <tr>
                        <th>新密码确认<span class="hint">*</span></th>
                        <td><input name="newpwd2" type="password" value="" /></td>
                        <th><input type="hidden" name="username" value="{$username}" /></th>
                        <td></td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script>
    function submitForm() {
        var username = $("input[name=username]").val();
        var newpwd = $("input[name=newpwd]").val();
        var newpwd2 = $("input[name=newpwd2]").val();
        if(!newpwd){
            alert("新密码不能为空");
            return false;
        }
        if(newpwd!=newpwd2){
            alert("新密码两次输入不一致");
            return false;
        }
        $.ajax({
            url:"/admin/user/passwd",
            data: {username:username, newpwd:newpwd, newpwd2:newpwd2},
            type:"POST", dataType:"JSON",
            success: function(data){
                if(data.status){
                    alert("密码修改成功");
                    location.reload();
                }else{
                    alert(data.info);
                }
            }
        });
    }
</script>
<include file="Public:footer" />
